home *** CD-ROM | disk | FTP | other *** search
/ PC go! 2008 March / PCgo 2008-03 (CD).iso / interface / static / Webde_SmartInstall.exe / kostenprotokoll_js / CalendarPopup.js next >
Encoding:
JavaScript  |  2007-05-02  |  71.0 KB  |  1,611 lines

  1. // ===================================================================
  2. // Author: Matt Kruse <matt@mattkruse.com>
  3. // WWW: http://www.mattkruse.com/
  4. //
  5. // NOTICE: You may use this code for any purpose, commercial or
  6. // private, without any further permission from the author. You may
  7. // remove this notice from your final code if you wish, however it is
  8. // appreciated by the author if at least my web site address is kept.
  9. //
  10. // You may *NOT* re-distribute this code in any way except through its
  11. // use. That means, you can include it in your product, or your web
  12. // site, or any other form where the code is actually being used. You
  13. // may not put the plain javascript up on your site for download or
  14. // include it in your javascript libraries for download. 
  15. // If you wish to share this code with others, please just point them
  16. // to the URL instead.
  17. // Please DO NOT link directly to my .js files from your site. Copy
  18. // the files to your server and use them there. Thank you.
  19. // ===================================================================
  20.  
  21.  
  22. /* SOURCE FILE: AnchorPosition.js */
  23.  
  24. /* 
  25. AnchorPosition.js
  26. Author: Matt Kruse
  27. Last modified: 10/11/02
  28.  
  29. DESCRIPTION: These functions find the position of an <A> tag in a document,
  30. so other elements can be positioned relative to it.
  31.  
  32. COMPATABILITY: Netscape 4.x,6.x,Mozilla, IE 5.x,6.x on Windows. Some small
  33. positioning errors - usually with Window positioning - occur on the 
  34. Macintosh platform.
  35.  
  36. FUNCTIONS:
  37. getAnchorPosition(anchorname)
  38.   Returns an Object() having .x and .y properties of the pixel coordinates
  39.   of the upper-left corner of the anchor. Position is relative to the PAGE.
  40.  
  41. getAnchorWindowPosition(anchorname)
  42.   Returns an Object() having .x and .y properties of the pixel coordinates
  43.   of the upper-left corner of the anchor, relative to the WHOLE SCREEN.
  44.  
  45. NOTES:
  46.  
  47. 1) For popping up separate browser windows, use getAnchorWindowPosition. 
  48.    Otherwise, use getAnchorPosition
  49.  
  50. 2) Your anchor tag MUST contain both NAME and ID attributes which are the 
  51.    same. For example:
  52.    <A NAME="test" ID="test"> </A>
  53.  
  54. 3) There must be at least a space between <A> </A> for IE5.5 to see the 
  55.    anchor tag correctly. Do not do <A></A> with no space.
  56. */ 
  57.  
  58. // getAnchorPosition(anchorname)
  59. //   This function returns an object having .x and .y properties which are the coordinates
  60. //   of the named anchor, relative to the page.
  61. function getAnchorPosition(anchorname) {
  62.     // This function will return an Object with x and y properties
  63.     var useWindow=false;
  64.     var coordinates=new Object();
  65.     var x=0,y=0;
  66.     // Browser capability sniffing
  67.     var use_gebi=false, use_css=false, use_layers=false;
  68.     if (document.getElementById) { use_gebi=true; }
  69.     else if (document.all) { use_css=true; }
  70.     else if (document.layers) { use_layers=true; }
  71.     // Logic to find position
  72.     if (use_gebi && document.all) {
  73.         x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
  74.         y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
  75.         }
  76.     else if (use_gebi) {
  77.         var o=document.getElementById(anchorname);
  78.         x=AnchorPosition_getPageOffsetLeft(o);
  79.         y=AnchorPosition_getPageOffsetTop(o);
  80.         }
  81.     else if (use_css) {
  82.         x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
  83.         y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
  84.         }
  85.     else if (use_layers) {
  86.         var found=0;
  87.         for (var i=0; i<document.anchors.length; i++) {
  88.             if (document.anchors[i].name==anchorname) { found=1; break; }
  89.             }
  90.         if (found==0) {
  91.             coordinates.x=0; coordinates.y=0; return coordinates;
  92.             }
  93.         x=document.anchors[i].x;
  94.         y=document.anchors[i].y;
  95.         }
  96.     else {
  97.         coordinates.x=0; coordinates.y=0; return coordinates;
  98.         }
  99.     coordinates.x=x;
  100.     coordinates.y=y;
  101.     return coordinates;
  102.     }
  103.  
  104. // getAnchorWindowPosition(anchorname)
  105. //   This function returns an object having .x and .y properties which are the coordinates
  106. //   of the named anchor, relative to the window
  107. function getAnchorWindowPosition(anchorname) {
  108.     var coordinates=getAnchorPosition(anchorname);
  109.     var x=0;
  110.     var y=0;
  111.     if (document.getElementById) {
  112.         if (isNaN(window.screenX)) {
  113.             x=coordinates.x-document.body.scrollLeft+window.screenLeft;
  114.             y=coordinates.y-document.body.scrollTop+window.screenTop;
  115.             }
  116.         else {
  117.             x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
  118.             y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
  119.             }
  120.         }
  121.     else if (document.all) {
  122.         x=coordinates.x-document.body.scrollLeft+window.screenLeft;
  123.         y=coordinates.y-document.body.scrollTop+window.screenTop;
  124.         }
  125.     else if (document.layers) {
  126.         x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
  127.         y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
  128.         }
  129.     coordinates.x=x;
  130.     coordinates.y=y;
  131.     return coordinates;
  132.     }
  133.  
  134. // Functions for IE to get position of an object
  135. function AnchorPosition_getPageOffsetLeft (el) {
  136.     var ol=el.offsetLeft;
  137.     while ((el=el.offsetParent) != null) { ol += el.offsetLeft; }
  138.     return ol;
  139.     }
  140. function AnchorPosition_getWindowOffsetLeft (el) {
  141.     return AnchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft;
  142.     }    
  143. function AnchorPosition_getPageOffsetTop (el) {
  144.     var ot=el.offsetTop;
  145.     while((el=el.offsetParent) != null) { ot += el.offsetTop; }
  146.     return ot;
  147.     }
  148. function AnchorPosition_getWindowOffsetTop (el) {
  149.     return AnchorPosition_getPageOffsetTop(el)-document.body.scrollTop;
  150.     }
  151.  
  152. /* SOURCE FILE: date.js */
  153.  
  154. // HISTORY
  155. // ------------------------------------------------------------------
  156. // May 17, 2003: Fixed bug in parseDate() for dates <1970
  157. // March 11, 2003: Added parseDate() function
  158. // March 11, 2003: Added "NNN" formatting option. Doesn't match up
  159. //                 perfectly with SimpleDateFormat formats, but 
  160. //                 backwards-compatability was required.
  161.  
  162. // ------------------------------------------------------------------
  163. // These functions use the same 'format' strings as the 
  164. // java.text.SimpleDateFormat class, with minor exceptions.
  165. // The format string consists of the following abbreviations:
  166. // 
  167. // Field        | Full Form          | Short Form
  168. // -------------+--------------------+-----------------------
  169. // Year         | yyyy (4 digits)    | yy (2 digits), y (2 or 4 digits)
  170. // Month        | MMM (name or abbr.)| MM (2 digits), M (1 or 2 digits)
  171. //              | NNN (abbr.)        |
  172. // Day of Month | dd (2 digits)      | d (1 or 2 digits)
  173. // Day of Week  | EE (name)          | E (abbr)
  174. // Hour (1-12)  | hh (2 digits)      | h (1 or 2 digits)
  175. // Hour (0-23)  | HH (2 digits)      | H (1 or 2 digits)
  176. // Hour (0-11)  | KK (2 digits)      | K (1 or 2 digits)
  177. // Hour (1-24)  | kk (2 digits)      | k (1 or 2 digits)
  178. // Minute       | mm (2 digits)      | m (1 or 2 digits)
  179. // Second       | ss (2 digits)      | s (1 or 2 digits)
  180. // AM/PM        | a                  |
  181. //
  182. // NOTE THE DIFFERENCE BETWEEN MM and mm! Month=MM, not mm!
  183. // Examples:
  184. //  "MMM d, y" matches: January 01, 2000
  185. //                      Dec 1, 1900
  186. //                      Nov 20, 00
  187. //  "M/d/yy"   matches: 01/20/00
  188. //                      9/2/00
  189. //  "MMM dd, yyyy hh:mm:ssa" matches: "January 01, 2000 12:30:45AM"
  190. // ------------------------------------------------------------------
  191.  
  192. var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
  193. var DAY_NAMES=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');
  194. function LZ(x) {return(x<0||x>9?"":"0")+x}
  195.  
  196. // ------------------------------------------------------------------
  197. // isDate ( date_string, format_string )
  198. // Returns true if date string matches format of format string and
  199. // is a valid date. Else returns false.
  200. // It is recommended that you trim whitespace around the value before
  201. // passing it to this function, as whitespace is NOT ignored!
  202. // ------------------------------------------------------------------
  203. function isDate(val,format) {
  204.     var date=getDateFromFormat(val,format);
  205.     if (date==0) { return false; }
  206.     return true;
  207.     }
  208.  
  209. // -------------------------------------------------------------------
  210. // compareDates(date1,date1format,date2,date2format)
  211. //   Compare two date strings to see which is greater.
  212. //   Returns:
  213. //   1 if date1 is greater than date2
  214. //   0 if date2 is greater than date1 of if they are the same
  215. //  -1 if either of the dates is in an invalid format
  216. // -------------------------------------------------------------------
  217. function compareDates(date1,dateformat1,date2,dateformat2) {
  218.     var d1=getDateFromFormat(date1,dateformat1);
  219.     var d2=getDateFromFormat(date2,dateformat2);
  220.     if (d1==0 || d2==0) {
  221.         return -1;
  222.         }
  223.     else if (d1 > d2) {
  224.         return 1;
  225.         }
  226.     return 0;
  227.     }
  228.  
  229. // ------------------------------------------------------------------
  230. // formatDate (date_object, format)
  231. // Returns a date in the output format specified.
  232. // The format string uses the same abbreviations as in getDateFromFormat()
  233. // ------------------------------------------------------------------
  234. function formatDate(date,format) {
  235.     format=format+"";
  236.     var result="";
  237.     var i_format=0;
  238.     var c="";
  239.     var token="";
  240.     var y=date.getYear()+"";
  241.     var M=date.getMonth()+1;
  242.     var d=date.getDate();
  243.     var E=date.getDay();
  244.     var H=date.getHours();
  245.     var m=date.getMinutes();
  246.     var s=date.getSeconds();
  247.     var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;
  248.     // Convert real date parts into formatted versions
  249.     var value=new Object();
  250.     if (y.length < 4) {y=""+(y-0+1900);}
  251.     value["y"]=""+y;
  252.     value["yyyy"]=y;
  253.     value["yy"]=y.substring(2,4);
  254.     value["M"]=M;
  255.     value["MM"]=LZ(M);
  256.     value["MMM"]=MONTH_NAMES[M-1];
  257.     value["NNN"]=MONTH_NAMES[M+11];
  258.     value["d"]=d;
  259.     value["dd"]=LZ(d);
  260.     value["E"]=DAY_NAMES[E+7];
  261.     value["EE"]=DAY_NAMES[E];
  262.     value["H"]=H;
  263.     value["HH"]=LZ(H);
  264.     if (H==0){value["h"]=12;}
  265.     else if (H>12){value["h"]=H-12;}
  266.     else {value["h"]=H;}
  267.     value["hh"]=LZ(value["h"]);
  268.     if (H>11){value["K"]=H-12;} else {value["K"]=H;}
  269.     value["k"]=H+1;
  270.     value["KK"]=LZ(value["K"]);
  271.     value["kk"]=LZ(value["k"]);
  272.     if (H > 11) { value["a"]="PM"; }
  273.     else { value["a"]="AM"; }
  274.     value["m"]=m;
  275.     value["mm"]=LZ(m);
  276.     value["s"]=s;
  277.     value["ss"]=LZ(s);
  278.     while (i_format < format.length) {
  279.         c=format.charAt(i_format);
  280.         token="";
  281.         while ((format.charAt(i_format)==c) && (i_format < format.length)) {
  282.             token += format.charAt(i_format++);
  283.             }
  284.         if (value[token] != null) { result=result + value[token]; }
  285.         else { result=result + token; }
  286.         }
  287.     return result;
  288.     }
  289.     
  290. // ------------------------------------------------------------------
  291. // Utility functions for parsing in getDateFromFormat()
  292. // ------------------------------------------------------------------
  293. function _isInteger(val) {
  294.     var digits="1234567890";
  295.     for (var i=0; i < val.length; i++) {
  296.         if (digits.indexOf(val.charAt(i))==-1) { return false; }
  297.         }
  298.     return true;
  299.     }
  300. function _getInt(str,i,minlength,maxlength) {
  301.     for (var x=maxlength; x>=minlength; x--) {
  302.         var token=str.substring(i,i+x);
  303.         if (token.length < minlength) { return null; }
  304.         if (_isInteger(token)) { return token; }
  305.         }
  306.     return null;
  307.     }
  308.     
  309. // ------------------------------------------------------------------
  310. // getDateFromFormat( date_string , format_string )
  311. //
  312. // This function takes a date string and a format string. It matches
  313. // If the date string matches the format string, it returns the 
  314. // getTime() of the date. If it does not match, it returns 0.
  315. // ------------------------------------------------------------------
  316. function getDateFromFormat(val,format) {
  317.     val=val+"";
  318.     format=format+"";
  319.     var i_val=0;
  320.     var i_format=0;
  321.     var c="";
  322.     var token="";
  323.     var token2="";
  324.     var x,y;
  325.     var now=new Date();
  326.     var year=now.getYear();
  327.     var month=now.getMonth()+1;
  328.     var date=1;
  329.     var hh=now.getHours();
  330.     var mm=now.getMinutes();
  331.     var ss=now.getSeconds();
  332.     var ampm="";
  333.     
  334.     while (i_format < format.length) {
  335.         // Get next token from format string
  336.         c=format.charAt(i_format);
  337.         token="";
  338.         while ((format.charAt(i_format)==c) && (i_format < format.length)) {
  339.             token += format.charAt(i_format++);
  340.             }
  341.         // Extract contents of value based on format token
  342.         if (token=="yyyy" || token=="yy" || token=="y") {
  343.             if (token=="yyyy") { x=4;y=4; }
  344.             if (token=="yy")   { x=2;y=2; }
  345.             if (token=="y")    { x=2;y=4; }
  346.             year=_getInt(val,i_val,x,y);
  347.             if (year==null) { return 0; }
  348.             i_val += year.length;
  349.             if (year.length==2) {
  350.                 if (year > 70) { year=1900+(year-0); }
  351.                 else { year=2000+(year-0); }
  352.                 }
  353.             }
  354.         else if (token=="MMM"||token=="NNN"){
  355.             month=0;
  356.             for (var i=0; i<MONTH_NAMES.length; i++) {
  357.                 var month_name=MONTH_NAMES[i];
  358.                 if (val.substring(i_val,i_val+month_name.length).toLowerCase()==month_name.toLowerCase()) {
  359.                     if (token=="MMM"||(token=="NNN"&&i>11)) {
  360.                         month=i+1;
  361.                         if (month>12) { month -= 12; }
  362.                         i_val += month_name.length;
  363.                         break;
  364.                         }
  365.                     }
  366.                 }
  367.             if ((month < 1)||(month>12)){return 0;}
  368.             }
  369.         else if (token=="EE"||token=="E"){
  370.             for (var i=0; i<DAY_NAMES.length; i++) {
  371.                 var day_name=DAY_NAMES[i];
  372.                 if (val.substring(i_val,i_val+day_name.length).toLowerCase()==day_name.toLowerCase()) {
  373.                     i_val += day_name.length;
  374.                     break;
  375.                     }
  376.                 }
  377.             }
  378.         else if (token=="MM"||token=="M") {
  379.             month=_getInt(val,i_val,token.length,2);
  380.             if(month==null||(month<1)||(month>12)){return 0;}
  381.             i_val+=month.length;}
  382.         else if (token=="dd"||token=="d") {
  383.             date=_getInt(val,i_val,token.length,2);
  384.             if(date==null||(date<1)||(date>31)){return 0;}
  385.             i_val+=date.length;}
  386.         else if (token=="hh"||token=="h") {
  387.             hh=_getInt(val,i_val,token.length,2);
  388.             if(hh==null||(hh<1)||(hh>12)){return 0;}
  389.             i_val+=hh.length;}
  390.         else if (token=="HH"||token=="H") {
  391.             hh=_getInt(val,i_val,token.length,2);
  392.             if(hh==null||(hh<0)||(hh>23)){return 0;}
  393.             i_val+=hh.length;}
  394.         else if (token=="KK"||token=="K") {
  395.             hh=_getInt(val,i_val,token.length,2);
  396.             if(hh==null||(hh<0)||(hh>11)){return 0;}
  397.             i_val+=hh.length;}
  398.         else if (token=="kk"||token=="k") {
  399.             hh=_getInt(val,i_val,token.length,2);
  400.             if(hh==null||(hh<1)||(hh>24)){return 0;}
  401.             i_val+=hh.length;hh--;}
  402.         else if (token=="mm"||token=="m") {
  403.             mm=_getInt(val,i_val,token.length,2);
  404.             if(mm==null||(mm<0)||(mm>59)){return 0;}
  405.             i_val+=mm.length;}
  406.         else if (token=="ss"||token=="s") {
  407.             ss=_getInt(val,i_val,token.length,2);
  408.             if(ss==null||(ss<0)||(ss>59)){return 0;}
  409.             i_val+=ss.length;}
  410.         else if (token=="a") {
  411.             if (val.substring(i_val,i_val+2).toLowerCase()=="am") {ampm="AM";}
  412.             else if (val.substring(i_val,i_val+2).toLowerCase()=="pm") {ampm="PM";}
  413.             else {return 0;}
  414.             i_val+=2;}
  415.         else {
  416.             if (val.substring(i_val,i_val+token.length)!=token) {return 0;}
  417.             else {i_val+=token.length;}
  418.             }
  419.         }
  420.     // If there are any trailing characters left in the value, it doesn't match
  421.     if (i_val != val.length) { return 0; }
  422.     // Is date valid for month?
  423.     if (month==2) {
  424.         // Check for leap year
  425.         if ( ( (year%4==0)&&(year%100 != 0) ) || (year%400==0) ) { // leap year
  426.             if (date > 29){ return 0; }
  427.             }
  428.         else { if (date > 28) { return 0; } }
  429.         }
  430.     if ((month==4)||(month==6)||(month==9)||(month==11)) {
  431.         if (date > 30) { return 0; }
  432.         }
  433.     // Correct hours value
  434.     if (hh<12 && ampm=="PM") { hh=hh-0+12; }
  435.     else if (hh>11 && ampm=="AM") { hh-=12; }
  436.     var newdate=new Date(year,month-1,date,hh,mm,ss);
  437.     return newdate.getTime();
  438.     }
  439.  
  440. // ------------------------------------------------------------------
  441. // parseDate( date_string [, prefer_euro_format] )
  442. //
  443. // This function takes a date string and tries to match it to a
  444. // number of possible date formats to get the value. It will try to
  445. // match against the following international formats, in this order:
  446. // y-M-d   MMM d, y   MMM d,y   y-MMM-d   d-MMM-y  MMM d
  447. // M/d/y   M-d-y      M.d.y     MMM-d     M/d      M-d
  448. // d/M/y   d-M-y      d.M.y     d-MMM     d/M      d-M
  449. // A second argument may be passed to instruct the method to search
  450. // for formats like d/M/y (european format) before M/d/y (American).
  451. // Returns a Date object or null if no patterns match.
  452. // ------------------------------------------------------------------
  453. function parseDate(val) {
  454.     var preferEuro=(arguments.length==2)?arguments[1]:false;
  455.     generalFormats=new Array('y-M-d','MMM d, y','MMM d,y','y-MMM-d','d-MMM-y','MMM d');
  456.     monthFirst=new Array('M/d/y','M-d-y','M.d.y','MMM-d','M/d','M-d');
  457.     dateFirst =new Array('d/M/y','d-M-y','d.M.y','d-MMM','d/M','d-M');
  458.     var checkList=new Array('generalFormats',preferEuro?'dateFirst':'monthFirst',preferEuro?'monthFirst':'dateFirst');
  459.     var d=null;
  460.     for (var i=0; i<checkList.length; i++) {
  461.         var l=window[checkList[i]];
  462.         for (var j=0; j<l.length; j++) {
  463.             d=getDateFromFormat(val,l[j]);
  464.             if (d!=0) { return new Date(d); }
  465.             }
  466.         }
  467.     return null;
  468.     }
  469.  
  470. /* SOURCE FILE: PopupWindow.js */
  471.  
  472. /* 
  473. PopupWindow.js
  474. Author: Matt Kruse
  475. Last modified: 02/16/04
  476.  
  477. DESCRIPTION: This object allows you to easily and quickly popup a window
  478. in a certain place. The window can either be a DIV or a separate browser
  479. window.
  480.  
  481. COMPATABILITY: Works with Netscape 4.x, 6.x, IE 5.x on Windows. Some small
  482. positioning errors - usually with Window positioning - occur on the 
  483. Macintosh platform. Due to bugs in Netscape 4.x, populating the popup 
  484. window with <STYLE> tags may cause errors.
  485.  
  486. USAGE:
  487. // Create an object for a WINDOW popup
  488. var win = new PopupWindow(); 
  489.  
  490. // Create an object for a DIV window using the DIV named 'mydiv'
  491. var win = new PopupWindow('mydiv'); 
  492.  
  493. // Set the window to automatically hide itself when the user clicks 
  494. // anywhere else on the page except the popup
  495. win.autoHide(); 
  496.  
  497. // Show the window relative to the anchor name passed in
  498. win.showPopup(anchorname);
  499.  
  500. // Hide the popup
  501. win.hidePopup();
  502.  
  503. // Set the size of the popup window (only applies to WINDOW popups
  504. win.setSize(width,height);
  505.  
  506. // Populate the contents of the popup window that will be shown. If you 
  507. // change the contents while it is displayed, you will need to refresh()
  508. win.populate(string);
  509.  
  510. // set the URL of the window, rather than populating its contents
  511. // manually
  512. win.setUrl("http://www.site.com/");
  513.  
  514. // Refresh the contents of the popup
  515. win.refresh();
  516.  
  517. // Specify how many pixels to the right of the anchor the popup will appear
  518. win.offsetX = 50;
  519.  
  520. // Specify how many pixels below the anchor the popup will appear
  521. win.offsetY = 100;
  522.  
  523. NOTES:
  524. 1) Requires the functions in AnchorPosition.js
  525.  
  526. 2) Your anchor tag MUST contain both NAME and ID attributes which are the 
  527.    same. For example:
  528.    <A NAME="test" ID="test"> </A>
  529.  
  530. 3) There must be at least a space between <A> </A> for IE5.5 to see the 
  531.    anchor tag correctly. Do not do <A></A> with no space.
  532.  
  533. 4) When a PopupWindow object is created, a handler for 'onmouseup' is
  534.    attached to any event handler you may have already defined. Do NOT define
  535.    an event handler for 'onmouseup' after you define a PopupWindow object or
  536.    the autoHide() will not work correctly.
  537. */ 
  538.  
  539. // Set the position of the popup window based on the anchor
  540. function PopupWindow_getXYPosition(anchorname) {
  541.     var coordinates;
  542.     if (this.type == "WINDOW") {
  543.         coordinates = getAnchorWindowPosition(anchorname);
  544.         }
  545.     else {
  546.         coordinates = getAnchorPosition(anchorname);
  547.         }
  548.     this.x = coordinates.x;
  549.     this.y = coordinates.y;
  550.     }
  551. // Set width/height of DIV/popup window
  552. function PopupWindow_setSize(width,height) {
  553.     this.width = width;
  554.     this.height = height;
  555.     }
  556. // Fill the window with contents
  557. function PopupWindow_populate(contents) {
  558.     this.contents = contents;
  559.     this.populated = false;
  560.     }
  561. // Set the URL to go to
  562. function PopupWindow_setUrl(url) {
  563.     this.url = url;
  564.     }
  565. // Set the window popup properties
  566. function PopupWindow_setWindowProperties(props) {
  567.     this.windowProperties = props;
  568.     }
  569. // Refresh the displayed contents of the popup
  570. function PopupWindow_refresh() {
  571.     if (this.divName != null) {
  572.         // refresh the DIV object
  573.         if (this.use_gebi) {
  574.             document.getElementById(this.divName).innerHTML = this.contents;
  575.             }
  576.         else if (this.use_css) { 
  577.             document.all[this.divName].innerHTML = this.contents;
  578.             }
  579.         else if (this.use_layers) { 
  580.             var d = document.layers[this.divName]; 
  581.             d.document.open();
  582.             d.document.writeln(this.contents);
  583.             d.document.close();
  584.             }
  585.         }
  586.     else {
  587.         if (this.popupWindow != null && !this.popupWindow.closed) {
  588.             if (this.url!="") {
  589.                 this.popupWindow.location.href=this.url;
  590.                 }
  591.             else {
  592.                 this.popupWindow.document.open();
  593.                 this.popupWindow.document.writeln(this.contents);
  594.                 this.popupWindow.document.close();
  595.             }
  596.             this.popupWindow.focus();
  597.             }
  598.         }
  599.     }
  600. // Position and show the popup, relative to an anchor object
  601. function PopupWindow_showPopup(anchorname) {
  602.     this.getXYPosition(anchorname);
  603.     this.x += this.offsetX;
  604.     this.y += this.offsetY;
  605.     if (!this.populated && (this.contents != "")) {
  606.         this.populated = true;
  607.         this.refresh();
  608.         }
  609.     if (this.divName != null) {
  610.         // Show the DIV object
  611.         if (this.use_gebi) {
  612.             document.getElementById(this.divName).style.left = this.x + "px";
  613.             document.getElementById(this.divName).style.top = this.y + "px";
  614.             document.getElementById(this.divName).style.visibility = "visible";
  615.             }
  616.         else if (this.use_css) {
  617.             document.all[this.divName].style.left = this.x;
  618.             document.all[this.divName].style.top = this.y;
  619.             document.all[this.divName].style.visibility = "visible";
  620.             }
  621.         else if (this.use_layers) {
  622.             document.layers[this.divName].left = this.x;
  623.             document.layers[this.divName].top = this.y;
  624.             document.layers[this.divName].visibility = "visible";
  625.             }
  626.         }
  627.     else {
  628.         if (this.popupWindow == null || this.popupWindow.closed) {
  629.             // If the popup window will go off-screen, move it so it doesn't
  630.             if (this.x<0) { this.x=0; }
  631.             if (this.y<0) { this.y=0; }
  632.             if (screen && screen.availHeight) {
  633.                 if ((this.y + this.height) > screen.availHeight) {
  634.                     this.y = screen.availHeight - this.height;
  635.                     }
  636.                 }
  637.             if (screen && screen.availWidth) {
  638.                 if ((this.x + this.width) > screen.availWidth) {
  639.                     this.x = screen.availWidth - this.width;
  640.                     }
  641.                 }
  642.             var avoidAboutBlank = window.opera || ( document.layers && !navigator.mimeTypes['*'] ) || navigator.vendor == 'KDE' || ( document.childNodes && !document.all && !navigator.taintEnabled );
  643.             this.popupWindow = window.open(avoidAboutBlank?"":"about:blank","window_"+anchorname,this.windowProperties+",width="+this.width+",height="+this.height+",screenX="+this.x+",left="+this.x+",screenY="+this.y+",top="+this.y+"");
  644.             }
  645.         this.refresh();
  646.         }
  647.     }
  648. // Hide the popup
  649. function PopupWindow_hidePopup() {
  650.     if (this.divName != null) {
  651.         if (this.use_gebi) {
  652.             document.getElementById(this.divName).style.visibility = "hidden";
  653.             }
  654.         else if (this.use_css) {
  655.             document.all[this.divName].style.visibility = "hidden";
  656.             }
  657.         else if (this.use_layers) {
  658.             document.layers[this.divName].visibility = "hidden";
  659.             }
  660.         }
  661.         if (document.all) {
  662.             if (document.getElementById('CalFrom').style.visibility === 'hidden' &&
  663.                 document.getElementById('CalTo').style.visibility === 'hidden' &&
  664.                 (!kp.CSVBox.style.display || kp.CSVBox.style.display === 'none')) {
  665.                 document.getElementById('Connections').style.visibility = 'visible';
  666.             }
  667.         }
  668.     else {
  669.         if (this.popupWindow && !this.popupWindow.closed) {
  670.             
  671.             this.popupWindow.close();
  672.             this.popupWindow = null;
  673.             }
  674.         }
  675.     }
  676. // Pass an event and return whether or not it was the popup DIV that was clicked
  677. function PopupWindow_isClicked(e) {
  678.     if (this.divName != null) {
  679.         if (this.use_layers) {
  680.             var clickX = e.pageX;
  681.             var clickY = e.pageY;
  682.             var t = document.layers[this.divName];
  683.             if ((clickX > t.left) && (clickX < t.left+t.clip.width) && (clickY > t.top) && (clickY < t.top+t.clip.height)) {
  684.                 return true;
  685.                 }
  686.             else { return false; }
  687.             }
  688.         else if (document.all) { // Need to hard-code this to trap IE for error-handling
  689.             var t = window.event.srcElement;
  690.             while (t.parentElement != null) {
  691.                 if (t.id==this.divName) {
  692.                     return true;
  693.                     }
  694.                 t = t.parentElement;
  695.                 }
  696.             return false;
  697.             }
  698.         else if (this.use_gebi && e) {
  699.             var t = e.originalTarget;
  700.             if (t.parentNode) {
  701.                 while (t.parentNode != null) {
  702.                     if (t.id == this.divName) {
  703.                         return true;
  704.                     }
  705.                     t = t.parentNode;
  706.                 }
  707.             }
  708.             return false;
  709.             }
  710.         return false;
  711.         }
  712.     return false;
  713.     }
  714.  
  715. // Check an onMouseDown event to see if we should hide
  716. function PopupWindow_hideIfNotClicked(e) {
  717.     if (this.autoHideEnabled && !this.isClicked(e)) {
  718.         if (document.getElementById('CalFrom').style.visibility === 'hidden' &&
  719.             document.getElementById('CalTo').style.visibility === 'hidden' &&
  720.             (!kp.CSVBox.style.display || kp.CSVBox.style.display === 'none')) {
  721.             document.getElementById('Connections').style.visibility = 'visible';
  722.         }
  723.         this.hidePopup();
  724.     }
  725. }
  726. // Call this to make the DIV disable automatically when mouse is clicked outside it
  727. function PopupWindow_autoHide() {
  728.     this.autoHideEnabled = true;
  729.     }
  730. // This global function checks all PopupWindow objects onmouseup to see if they should be hidden
  731. function PopupWindow_hidePopupWindows(e) {
  732.     for (var i=0; i<popupWindowObjects.length; i++) {
  733.         if (popupWindowObjects[i] != null) {
  734.             var p = popupWindowObjects[i];
  735.             p.hideIfNotClicked(e);
  736.             }
  737.         }
  738.     }
  739. // Run this immediately to attach the event listener
  740. function PopupWindow_attachListener() {
  741.     if (document.layers) {
  742.         document.captureEvents(Event.MOUSEUP);
  743.         }
  744.     window.popupWindowOldEventListener = document.onmouseup;
  745.     if (window.popupWindowOldEventListener != null) {
  746.         document.onmouseup = new Function("window.popupWindowOldEventListener(); PopupWindow_hidePopupWindows();");
  747.         }
  748.     else {
  749.         document.onmouseup = PopupWindow_hidePopupWindows;
  750.         }
  751.     }
  752. // CONSTRUCTOR for the PopupWindow object
  753. // Pass it a DIV name to use a DHTML popup, otherwise will default to window popup
  754. function PopupWindow() {
  755.     if (!window.popupWindowIndex) { window.popupWindowIndex = 0; }
  756.     if (!window.popupWindowObjects) { window.popupWindowObjects = new Array(); }
  757.     if (!window.listenerAttached) {
  758.         window.listenerAttached = true;
  759.         PopupWindow_attachListener();
  760.         }
  761.     this.index = popupWindowIndex++;
  762.     popupWindowObjects[this.index] = this;
  763.     this.divName = null;
  764.     this.popupWindow = null;
  765.     this.width=0;
  766.     this.height=0;
  767.     this.populated = false;
  768.     this.visible = false;
  769.     this.autoHideEnabled = false;
  770.     
  771.     this.contents = "";
  772.     this.url="";
  773.     this.windowProperties="toolbar=no,location=no,status=no,menubar=no,scrollbars=auto,resizable,alwaysRaised,dependent,titlebar=no";
  774.     if (arguments.length>0) {
  775.         this.type="DIV";
  776.         this.divName = arguments[0];
  777.         }
  778.     else {
  779.         this.type="WINDOW";
  780.         }
  781.     this.use_gebi = false;
  782.     this.use_css = false;
  783.     this.use_layers = false;
  784.     if (document.getElementById) { this.use_gebi = true; }
  785.     else if (document.all) { this.use_css = true; }
  786.     else if (document.layers) { this.use_layers = true; }
  787.     else { this.type = "WINDOW"; }
  788.     this.offsetX = 0;
  789.     this.offsetY = 0;
  790.     // Method mappings
  791.     this.getXYPosition = PopupWindow_getXYPosition;
  792.     this.populate = PopupWindow_populate;
  793.     this.setUrl = PopupWindow_setUrl;
  794.     this.setWindowProperties = PopupWindow_setWindowProperties;
  795.     this.refresh = PopupWindow_refresh;
  796.     this.showPopup = PopupWindow_showPopup;
  797.     this.hidePopup = PopupWindow_hidePopup;
  798.     this.setSize = PopupWindow_setSize;
  799.     this.isClicked = PopupWindow_isClicked;
  800.     this.autoHide = PopupWindow_autoHide;
  801.     this.hideIfNotClicked = PopupWindow_hideIfNotClicked;
  802.     }
  803.  
  804. /* SOURCE FILE: CalendarPopup.js */
  805.  
  806. // HISTORY
  807. // ------------------------------------------------------------------
  808. // Feb 7, 2005: Fixed a CSS styles to use px unit
  809. // March 29, 2004: Added check in select() method for the form field
  810. //      being disabled. If it is, just return and don't do anything.
  811. // March 24, 2004: Fixed bug - when month name and abbreviations were
  812. //      changed, date format still used original values.
  813. // January 26, 2004: Added support for drop-down month and year
  814. //      navigation (Thanks to Chris Reid for the idea)
  815. // September 22, 2003: Fixed a minor problem in YEAR calendar with
  816. //      CSS prefix.
  817. // August 19, 2003: Renamed the function to get styles, and made it
  818. //      work correctly without an object reference
  819. // August 18, 2003: Changed showYearNavigation and 
  820. //      showYearNavigationInput to optionally take an argument of
  821. //      true or false
  822. // July 31, 2003: Added text input option for year navigation.
  823. //      Added a per-calendar CSS prefix option to optionally use 
  824. //      different styles for different calendars.
  825. // July 29, 2003: Fixed bug causing the Today link to be clickable 
  826. //      even though today falls in a disabled date range.
  827. //      Changed formatting to use pure CSS, allowing greater control
  828. //      over look-and-feel options.
  829. // June 11, 2003: Fixed bug causing the Today link to be unselectable
  830. //      under certain cases when some days of week are disabled
  831. // March 14, 2003: Added ability to disable individual dates or date
  832. //      ranges, display as light gray and strike-through
  833. // March 14, 2003: Removed dependency on graypixel.gif and instead 
  834. ///     use table border coloring
  835. // March 12, 2003: Modified showCalendar() function to allow optional
  836. //      start-date parameter
  837. // March 11, 2003: Modified select() function to allow optional
  838. //      start-date parameter
  839. /* 
  840. DESCRIPTION: This object implements a popup calendar to allow the user to
  841. select a date, month, quarter, or year.
  842.  
  843. COMPATABILITY: Works with Netscape 4.x, 6.x, IE 5.x on Windows. Some small
  844. positioning errors - usually with Window positioning - occur on the 
  845. Macintosh platform.
  846. The calendar can be modified to work for any location in the world by 
  847. changing which weekday is displayed as the first column, changing the month
  848. names, and changing the column headers for each day.
  849.  
  850. USAGE:
  851. // Create a new CalendarPopup object of type WINDOW
  852. var cal = new CalendarPopup(); 
  853.  
  854. // Create a new CalendarPopup object of type DIV using the DIV named 'mydiv'
  855. var cal = new CalendarPopup('mydiv'); 
  856.  
  857. // Easy method to link the popup calendar with an input box. 
  858. cal.select(inputObject, anchorname, dateFormat);
  859. // Same method, but passing a default date other than the field's current value
  860. cal.select(inputObject, anchorname, dateFormat, '01/02/2000');
  861. // This is an example call to the popup calendar from a link to populate an 
  862. // input box. Note that to use this, date.js must also be included!!
  863. <A HREF="#" onClick="cal.select(document.forms[0].date,'anchorname','MM/dd/yyyy'); return false;">Select</A>
  864.  
  865. // Set the type of date select to be used. By default it is 'date'.
  866. cal.setDisplayType(type);
  867.  
  868. // When a date, month, quarter, or year is clicked, a function is called and
  869. // passed the details. You must write this function, and tell the calendar
  870. // popup what the function name is.
  871. // Function to be called for 'date' select receives y, m, d
  872. cal.setReturnFunction(functionname);
  873. // Function to be called for 'month' select receives y, m
  874. cal.setReturnMonthFunction(functionname);
  875. // Function to be called for 'quarter' select receives y, q
  876. cal.setReturnQuarterFunction(functionname);
  877. // Function to be called for 'year' select receives y
  878. cal.setReturnYearFunction(functionname);
  879.  
  880. // Show the calendar relative to a given anchor
  881. cal.showCalendar(anchorname);
  882.  
  883. // Hide the calendar. The calendar is set to autoHide automatically
  884. cal.hideCalendar();
  885.  
  886. // Set the month names to be used. Default are English month names
  887. cal.setMonthNames("January","February","March",...);
  888.  
  889. // Set the month abbreviations to be used. Default are English month abbreviations
  890. cal.setMonthAbbreviations("Jan","Feb","Mar",...);
  891.  
  892. // Show navigation for changing by the year, not just one month at a time
  893. cal.showYearNavigation();
  894.  
  895. // Show month and year dropdowns, for quicker selection of month of dates
  896. cal.showNavigationDropdowns();
  897.  
  898. // Set the text to be used above each day column. The days start with 
  899. // sunday regardless of the value of WeekStartDay
  900. cal.setDayHeaders("S","M","T",...);
  901.  
  902. // Set the day for the first column in the calendar grid. By default this
  903. // is Sunday (0) but it may be changed to fit the conventions of other
  904. // countries.
  905. cal.setWeekStartDay(1); // week is Monday - Sunday
  906.  
  907. // Set the weekdays which should be disabled in the 'date' select popup. You can
  908. // then allow someone to only select week end dates, or Tuedays, for example
  909. cal.setDisabledWeekDays(0,1); // To disable selecting the 1st or 2nd days of the week
  910.  
  911. // Selectively disable individual days or date ranges. Disabled days will not
  912. // be clickable, and show as strike-through text on current browsers.
  913. // Date format is any format recognized by parseDate() in date.js
  914. // Pass a single date to disable:
  915. cal.addDisabledDates("2003-01-01");
  916. // Pass null as the first parameter to mean "anything up to and including" the
  917. // passed date:
  918. cal.addDisabledDates(null, "01/02/03");
  919. // Pass null as the second parameter to mean "including the passed date and
  920. // anything after it:
  921. cal.addDisabledDates("Jan 01, 2003", null);
  922. // Pass two dates to disable all dates inbetween and including the two
  923. cal.addDisabledDates("January 01, 2003", "Dec 31, 2003");
  924.  
  925. // When the 'year' select is displayed, set the number of years back from the 
  926. // current year to start listing years. Default is 2.
  927. // This is also used for year drop-down, to decide how many years +/- to display
  928. cal.setYearSelectStartOffset(2);
  929.  
  930. // Text for the word "Today" appearing on the calendar
  931. cal.setTodayText("Today");
  932.  
  933. // The calendar uses CSS classes for formatting. If you want your calendar to
  934. // have unique styles, you can set the prefix that will be added to all the
  935. // classes in the output.
  936. // For example, normal output may have this:
  937. //     <SPAN CLASS="cpTodayTextDisabled">Today<SPAN>
  938. // But if you set the prefix like this:
  939. cal.setCssPrefix("Test");
  940. // The output will then look like:
  941. //     <SPAN CLASS="TestcpTodayTextDisabled">Today<SPAN>
  942. // And you can define that style somewhere in your page.
  943.  
  944. // When using Year navigation, you can make the year be an input box, so
  945. // the user can manually change it and jump to any year
  946. cal.showYearNavigationInput();
  947.  
  948. // Set the calendar offset to be different than the default. By default it
  949. // will appear just below and to the right of the anchorname. So if you have
  950. // a text box where the date will go and and anchor immediately after the
  951. // text box, the calendar will display immediately under the text box.
  952. cal.offsetX = 20;
  953. cal.offsetY = 20;
  954.  
  955. NOTES:
  956. 1) Requires the functions in AnchorPosition.js and PopupWindow.js
  957.  
  958. 2) Your anchor tag MUST contain both NAME and ID attributes which are the 
  959.    same. For example:
  960.    <A NAME="test" ID="test"> </A>
  961.  
  962. 3) There must be at least a space between <A> </A> for IE5.5 to see the 
  963.    anchor tag correctly. Do not do <A></A> with no space.
  964.  
  965. 4) When a CalendarPopup object is created, a handler for 'onmouseup' is
  966.    attached to any event handler you may have already defined. Do NOT define
  967.    an event handler for 'onmouseup' after you define a CalendarPopup object 
  968.    or the autoHide() will not work correctly.
  969.    
  970. 5) The calendar popup display uses style sheets to make it look nice.
  971.  
  972. */ 
  973.  
  974. // CONSTRUCTOR for the CalendarPopup Object
  975. function CalendarPopup() {
  976.     var c;
  977.     if (arguments.length>0) {
  978.         c = new PopupWindow(arguments[0]);
  979.         }
  980.     else {
  981.         c = new PopupWindow();
  982.         c.setSize(150,175);
  983.         }
  984.     c.offsetX = 0;
  985.     c.offsetY = 25;
  986.     c.autoHide();
  987.     // Calendar-specific properties
  988.     c.monthNames = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
  989.     c.monthAbbreviations = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
  990.     c.dayHeaders = new Array("S","M","T","W","T","F","S");
  991.     c.returnFunction = "CP_tmpReturnFunction";
  992.     c.returnMonthFunction = "CP_tmpReturnMonthFunction";
  993.     c.returnQuarterFunction = "CP_tmpReturnQuarterFunction";
  994.     c.returnYearFunction = "CP_tmpReturnYearFunction";
  995.     
  996.     c.weekStartDay = 0;
  997.     c.isShowYearNavigation = false;
  998.     c.displayType = "date";
  999.     c.disabledWeekDays = new Object();
  1000.     c.disabledDatesExpression = "";
  1001.     c.yearSelectStartOffset = 2;
  1002.     c.currentDate = null;
  1003.     c.todayText="Today";
  1004.     c.cssPrefix="";
  1005.     c.isShowNavigationDropdowns=false;
  1006.     c.isShowYearNavigationInput=false;
  1007.     window.CP_additionalReturnFunction = '';
  1008.     window.CP_calendarObject = null;
  1009.     window.CP_targetInput = null;
  1010.     window.CP_dateFormat = "MM/dd/yyyy";
  1011.     window.CP_additionalReturnFunction = '';
  1012.     // Method mappings
  1013.     c.copyMonthNamesToWindow = CP_copyMonthNamesToWindow;
  1014.     c.setReturnFunction = CP_setReturnFunction;
  1015.     c.setReturnMonthFunction = CP_setReturnMonthFunction;
  1016.     c.setReturnQuarterFunction = CP_setReturnQuarterFunction;
  1017.     c.setReturnYearFunction = CP_setReturnYearFunction;
  1018.     c.setMonthNames = CP_setMonthNames;
  1019.     c.setMonthAbbreviations = CP_setMonthAbbreviations;
  1020.     c.setDayHeaders = CP_setDayHeaders;
  1021.     c.setWeekStartDay = CP_setWeekStartDay;
  1022.     c.setDisplayType = CP_setDisplayType;
  1023.     c.setDisabledWeekDays = CP_setDisabledWeekDays;
  1024.     c.setAdditionalReturnFunction = CP_setAdditionalReturnFunction;
  1025.     c.addDisabledDates = CP_addDisabledDates;
  1026.     c.addDisableHolidaysBegin = CP_addDisableHolidaysBegin;
  1027.     c.addDisableHolidaysEnd = CP_addDisableHolidaysEnd;
  1028.     c.setYearSelectStartOffset = CP_setYearSelectStartOffset;
  1029.     c.setTodayText = CP_setTodayText;
  1030.     c.showYearNavigation = CP_showYearNavigation;
  1031.     c.showCalendar = CP_showCalendar;
  1032.     c.hideCalendar = CP_hideCalendar;
  1033.     c.getStyles = getCalendarStyles;
  1034.     c.refreshCalendar = CP_refreshCalendar;
  1035.     c.getCalendar = CP_getCalendar;
  1036.     c.select = CP_select;
  1037.     c.setCssPrefix = CP_setCssPrefix;
  1038.     c.showNavigationDropdowns = CP_showNavigationDropdowns;
  1039.     c.showYearNavigationInput = CP_showYearNavigationInput;
  1040.     c.copyMonthNamesToWindow();
  1041.     c.clearDisabledDays = CP_clearDisabledDays;
  1042.     // Return the object
  1043.     return c;
  1044.     }
  1045. function CP_copyMonthNamesToWindow() {
  1046.     // Copy these values over to the date.js 
  1047.     if (typeof(window.MONTH_NAMES)!="undefined" && window.MONTH_NAMES!=null) {
  1048.         window.MONTH_NAMES = new Array();
  1049.         for (var i=0; i<this.monthNames.length; i++) {
  1050.             window.MONTH_NAMES[window.MONTH_NAMES.length] = this.monthNames[i];
  1051.         }
  1052.         for (var i=0; i<this.monthAbbreviations.length; i++) {
  1053.             window.MONTH_NAMES[window.MONTH_NAMES.length] = this.monthAbbreviations[i];
  1054.         }
  1055.     }
  1056. }
  1057.  
  1058. // Set an additional return function to be called after click on a date
  1059. function CP_setAdditionalReturnFunction(function_name) {
  1060.     this.CP_additionalReturnFunction = function_name;
  1061. }
  1062.  
  1063. // Temporary default functions to be called when items clicked, so no error is thrown
  1064. function CP_tmpReturnFunction(y,m,d) {
  1065.     if (window.CP_targetInput!=null) {
  1066.         var dt = new Date(y,m-1,d,0,0,0);
  1067.         if (window.CP_calendarObject!=null) { window.CP_calendarObject.copyMonthNamesToWindow(); }
  1068.         window.CP_targetInput.value = formatDate(dt,window.CP_dateFormat);
  1069.  
  1070.         if (window.CP_calendarObject.CP_additionalReturnFunction != '' &&
  1071.             window.CP_calendarObject.CP_additionalReturnFunction != undefined) {
  1072.             eval(window.CP_calendarObject.CP_additionalReturnFunction + "();");
  1073.         }
  1074.     }
  1075.     else {
  1076.         alert('Use setReturnFunction() to define which function will get the clicked results!'); 
  1077.         }
  1078.     }
  1079. function CP_tmpReturnMonthFunction(y,m) { 
  1080.     alert('Use setReturnMonthFunction() to define which function will get the clicked results!\nYou clicked: year='+y+' , month='+m); 
  1081.     }
  1082. function CP_tmpReturnQuarterFunction(y,q) { 
  1083.     alert('Use setReturnQuarterFunction() to define which function will get the clicked results!\nYou clicked: year='+y+' , quarter='+q); 
  1084.     }
  1085. function CP_tmpReturnYearFunction(y) { 
  1086.     alert('Use setReturnYearFunction() to define which function will get the clicked results!\nYou clicked: year='+y); 
  1087.     }
  1088.  
  1089. // Set the name of the functions to call to get the clicked item
  1090. function CP_setReturnFunction(name) { this.returnFunction = name; }
  1091. function CP_setReturnMonthFunction(name) { this.returnMonthFunction = name; }
  1092. function CP_setReturnQuarterFunction(name) { this.returnQuarterFunction = name; }
  1093. function CP_setReturnYearFunction(name) { this.returnYearFunction = name; }
  1094.  
  1095. // Over-ride the built-in month names
  1096. function CP_setMonthNames() {
  1097.     for (var i=0; i<arguments.length; i++) { this.monthNames[i] = arguments[i]; }
  1098.     this.copyMonthNamesToWindow();
  1099.     }
  1100.  
  1101. // Over-ride the built-in month abbreviations
  1102. function CP_setMonthAbbreviations() {
  1103.     for (var i=0; i<arguments.length; i++) { this.monthAbbreviations[i] = arguments[i]; }
  1104.     this.copyMonthNamesToWindow();
  1105.     }
  1106.  
  1107. // Over-ride the built-in column headers for each day
  1108. function CP_setDayHeaders() {
  1109.     for (var i=0; i<arguments.length; i++) { this.dayHeaders[i] = arguments[i]; }
  1110.     }
  1111.  
  1112. // Set the day of the week (0-7) that the calendar display starts on
  1113. // This is for countries other than the US whose calendar displays start on Monday(1), for example
  1114. function CP_setWeekStartDay(day) { this.weekStartDay = day; }
  1115.  
  1116. // Show next/last year navigation links
  1117. function CP_showYearNavigation() { this.isShowYearNavigation = (arguments.length>0)?arguments[0]:true; }
  1118.  
  1119. // Which type of calendar to display
  1120. function CP_setDisplayType(type) {
  1121.     if (type!="date"&&type!="week-end"&&type!="month"&&type!="quarter"&&type!="year") { alert("Invalid display type! Must be one of: date,week-end,month,quarter,year"); return false; }
  1122.     this.displayType=type;
  1123.     }
  1124.  
  1125. // How many years back to start by default for year display
  1126. function CP_setYearSelectStartOffset(num) { this.yearSelectStartOffset=num; }
  1127.  
  1128. // Set which weekdays should not be clickable
  1129. function CP_setDisabledWeekDays() {
  1130.     this.disabledWeekDays = new Object();
  1131.     for (var i=0; i<arguments.length; i++) { this.disabledWeekDays[arguments[i]] = true; }
  1132.     }
  1133.     
  1134. // Disable individual dates or ranges
  1135. // Builds an internal logical test which is run via eval() for efficiency
  1136. function CP_addDisabledDates(start, end) {
  1137.     if (arguments.length==1) { end=start; }
  1138.     if (start==null && end==null) { return; }
  1139.     if (this.disabledDatesExpression!="") { this.disabledDatesExpression+= "||"; }
  1140.     if (start!=null) { start = parseDate(start); start=""+start.getFullYear()+LZ(start.getMonth()+1)+LZ(start.getDate());}
  1141.     if (end!=null) { end=parseDate(end); end=""+end.getFullYear()+LZ(end.getMonth()+1)+LZ(end.getDate());}
  1142.     if (start==null) { this.disabledDatesExpression+="(ds<="+end+")"; }
  1143.     else if (end  ==null) { this.disabledDatesExpression+="(ds>="+start+")"; }
  1144.     else { this.disabledDatesExpression+="(ds>="+start+"&&ds<="+end+")"; }
  1145. }
  1146.  
  1147. // BadenWⁿrtemberg Feiertage abschalten
  1148. function CP_addDisableHolidaysBegin() {
  1149.     for (year=2006; year<2020; year++) { 
  1150.         if (this.disabledDatesExpression!="") { this.disabledDatesExpression+= "||"; }
  1151.         //Neujahrstag
  1152.         this.disabledDatesExpression+="(ds>="+year+"0101&&ds<="+year+"0102)";
  1153.         this.disabledDatesExpression+= "||";
  1154.         //Heilige Drei K÷nige
  1155.         this.disabledDatesExpression+="(ds>="+year+"0106&&ds<="+year+"0107)";
  1156.         this.disabledDatesExpression+= "||";
  1157.         //Karfreitag
  1158.         this.disabledDatesExpression+="(ds>="+feierTage(year, -2)+"&&ds<="+feierTage(year, -1)+")";
  1159.         this.disabledDatesExpression+= "||";
  1160.         //Ostermontag
  1161.         this.disabledDatesExpression+="(ds>="+feierTage(year, 1)+"&&ds<="+feierTage(year, 2)+")";
  1162.         this.disabledDatesExpression+= "||";
  1163.         //1. Mai
  1164.         this.disabledDatesExpression+="(ds>="+year+"0501&&ds<="+year+"0502)";
  1165.         this.disabledDatesExpression+= "||";
  1166.         //Christi Himmelfahrt
  1167.         this.disabledDatesExpression+="(ds>="+feierTage(year, 39)+"&&ds<="+feierTage(year, 40)+")";
  1168.         this.disabledDatesExpression+= "||";
  1169.         //Pfingstmontag
  1170.         this.disabledDatesExpression+="(ds>="+feierTage(year, 50)+"&&ds<="+feierTage(year, 51)+")";
  1171.         this.disabledDatesExpression+= "||";
  1172.         //Fronleichnam
  1173.         this.disabledDatesExpression+="(ds>="+feierTage(year, 60)+"&&ds<="+feierTage(year, 61)+")";
  1174.         this.disabledDatesExpression+= "||";
  1175.         //Tag der Deutschen Einheit
  1176.         this.disabledDatesExpression+="(ds>="+year+"1003&&ds<="+year+"1004)";
  1177.         this.disabledDatesExpression+= "||";
  1178.         //Allerheiligen
  1179.         this.disabledDatesExpression+="(ds>="+year+"1101&&ds<="+year+"1102)";
  1180.         this.disabledDatesExpression+= "||";
  1181.         //1. Weihnachtstag & 2. Weihnachtstag
  1182.         this.disabledDatesExpression+="(ds>="+year+"1225&&ds<="+year+"1227)";
  1183.     }    
  1184. }
  1185.  
  1186. function CP_addDisableHolidaysEnd() {
  1187.     for (year=2006; year<2020; year++) { 
  1188.         if (this.disabledDatesExpression!="") { this.disabledDatesExpression+= "||"; }
  1189.         //Neujahrstag
  1190.         this.disabledDatesExpression+="(ds>="+(year-1)+"3112&&ds<="+year+"0101)";
  1191.         this.disabledDatesExpression+= "||";
  1192.         //Heilige Drei K÷nige
  1193.         this.disabledDatesExpression+="(ds>="+year+"0105&&ds<="+year+"0106)";
  1194.         this.disabledDatesExpression+= "||";
  1195.         //Karfreitag
  1196.         this.disabledDatesExpression+="(ds>="+feierTage(year, -3)+"&&ds<="+feierTage(year, -2)+")";
  1197.         this.disabledDatesExpression+= "||";
  1198.         //Ostermontag
  1199.         this.disabledDatesExpression+="(ds>="+feierTage(year, 0)+"&&ds<="+feierTage(year, 1)+")";
  1200.         this.disabledDatesExpression+= "||";
  1201.         //1. Mai
  1202.         this.disabledDatesExpression+="(ds>="+year+"0430&&ds<="+year+"0501)";
  1203.         this.disabledDatesExpression+= "||";
  1204.         //Christi Himmelfahrt
  1205.         this.disabledDatesExpression+="(ds>="+feierTage(year, 38)+"&&ds<="+feierTage(year, 39)+")";
  1206.         this.disabledDatesExpression+= "||";
  1207.         //Pfingstmontag
  1208.         this.disabledDatesExpression+="(ds>="+feierTage(year, 49)+"&&ds<="+feierTage(year, 50)+")";
  1209.         this.disabledDatesExpression+= "||";
  1210.         //Fronleichnam
  1211.         this.disabledDatesExpression+="(ds>="+feierTage(year, 59)+"&&ds<="+feierTage(year, 60)+")";
  1212.         this.disabledDatesExpression+= "||";
  1213.         //Tag der Deutschen Einheit
  1214.         this.disabledDatesExpression+="(ds>="+year+"1002&&ds<="+year+"1003)";
  1215.         this.disabledDatesExpression+= "||";
  1216.         //Allerheiligen
  1217.         this.disabledDatesExpression+="(ds>="+year+"1031&&ds<="+year+"1101)";
  1218.         this.disabledDatesExpression+= "||";
  1219.         //1. Weihnachtstag & 2. Weihnachtstag
  1220.         this.disabledDatesExpression+="(ds>="+year+"1224&&ds<="+year+"1226)";
  1221.     }    
  1222. }
  1223.  
  1224. function feierTage(Jahr, TagesDifferenz)
  1225. { // Erstellt von Ralf Pfeifer (www.arstechnica.de)
  1226.  
  1227.     // Falls keine TagesDifferenz angegeben, TadgesDifferenz auf 0 setzen.
  1228.     if ((TagesDifferenz == "") || (TagesDifferenz == null)) { TagesDifferenz = 0; }
  1229.  
  1230.     var a = Jahr % 19;
  1231.     var d = (19 * a + 24) % 30;
  1232.     var Tag = d + (2 * (Jahr % 4) + 4 * (Jahr % 7) + 6 * d + 5) % 7;
  1233.     if ((Tag == 35) || ((Tag == 34) && (d == 28) && (a > 10))) { Tag -= 7; }
  1234.  
  1235.     var OsterDatum = new Date(Jahr, 2, 22)
  1236.     // 86400000 = 24 h * 60 min * 60 s * 1000 ms
  1237.     // Die Zahl 86400000 nicht ausklammern, sonst gibt's Probleme bei der Typumwandlung !!
  1238.     OsterDatum.setTime(OsterDatum.getTime() + 86400000 * TagesDifferenz + 86400000 * Tag)
  1239.  
  1240.     return ""+OsterDatum.getFullYear()+LZ(OsterDatum.getMonth()+1)+LZ(OsterDatum.getDate());
  1241. }
  1242.  
  1243.     
  1244. // Set the text to use for the "Today" link
  1245. function CP_setTodayText(text) {
  1246.     this.todayText = text;
  1247.     }
  1248.  
  1249. // Set the prefix to be added to all CSS classes when writing output
  1250. function CP_setCssPrefix(val) { 
  1251.     this.cssPrefix = val; 
  1252.     }
  1253.  
  1254. // Show the navigation as an dropdowns that can be manually changed
  1255. function CP_showNavigationDropdowns() { this.isShowNavigationDropdowns = (arguments.length>0)?arguments[0]:true; }
  1256.  
  1257. // Show the year navigation as an input box that can be manually changed
  1258. function CP_showYearNavigationInput() { this.isShowYearNavigationInput = (arguments.length>0)?arguments[0]:true; }
  1259.  
  1260. // Hide a calendar object
  1261. function CP_hideCalendar() {
  1262.     if (document.all) {
  1263.         if (document.getElementById('CalFrom').style.visibility === 'hidden' &&
  1264.             document.getElementById('CalTo').style.visibility === 'hidden' &&
  1265.             (!kp.CSVBox.style.display || kp.CSVBox.style.display === 'none')) {
  1266.             document.getElementById('Connections').style.visibility = 'visible';
  1267.         }
  1268.     }
  1269.     if (arguments.length > 0) {
  1270.         window.popupWindowObjects[arguments[0]].hidePopup();
  1271.     }
  1272.     else { this.hidePopup(); }
  1273.     }
  1274.  
  1275. // Refresh the contents of the calendar display
  1276. function CP_refreshCalendar(index) {
  1277.     var calObject = window.popupWindowObjects[index];
  1278.     if (arguments.length>1) { 
  1279.         calObject.populate(calObject.getCalendar(arguments[1],arguments[2],arguments[3],arguments[4],arguments[5]));
  1280.         }
  1281.     else {
  1282.         calObject.populate(calObject.getCalendar());
  1283.         }
  1284.     calObject.refresh();
  1285.     }
  1286.  
  1287. // Populate the calendar and display it
  1288. function CP_showCalendar(anchorname) {
  1289.     if (arguments.length>1) {
  1290.         if (arguments[1]==null||arguments[1]=="") {
  1291.             this.currentDate=new Date();
  1292.             }
  1293.         else {
  1294.             this.currentDate=new Date(parseDate(arguments[1]));
  1295.             }
  1296.         }
  1297.     this.populate(this.getCalendar());
  1298.     this.showPopup(anchorname);
  1299.     }
  1300.  
  1301. // Simple method to interface popup calendar with a text-entry box
  1302. function CP_select(inputobj, linkname, format) {
  1303.     var selectedDate=(arguments.length>3)?arguments[3]:null;
  1304.     if (!window.getDateFromFormat) {
  1305.         alert("calendar.select: To use this method you must also include 'date.js' for date formatting");
  1306.         return;
  1307.         }
  1308.     if (this.displayType!="date"&&this.displayType!="week-end") {
  1309.         alert("calendar.select: This function can only be used with displayType 'date' or 'week-end'");
  1310.         return;
  1311.         }
  1312.     if (inputobj.type!="text" && inputobj.type!="hidden" && inputobj.type!="textarea") { 
  1313.         alert("calendar.select: Input object passed is not a valid form input object"); 
  1314.         window.CP_targetInput=null;
  1315.         return;
  1316.         }
  1317.     if (inputobj.disabled) { return; } // Can't use calendar input on disabled form input!
  1318.     window.CP_targetInput = inputobj;
  1319.     window.CP_calendarObject = this;
  1320.  
  1321.     this.currentDate=null;
  1322.     var time=0;
  1323.     if (selectedDate!=null) {
  1324.         time = getDateFromFormat(selectedDate,format)
  1325.         }
  1326.     else if (inputobj.value!="") {
  1327.         time = getDateFromFormat(inputobj.value,format);
  1328.         }
  1329.     if (selectedDate!=null || inputobj.value!="") {
  1330.         if (time==0) { this.currentDate=null; }
  1331.         else { this.currentDate=new Date(time); }
  1332.         }
  1333.     window.CP_dateFormat = format;
  1334.     this.showCalendar(linkname);
  1335.     }
  1336.     
  1337. // Get style block needed to display the calendar correctly
  1338. function getCalendarStyles() {
  1339.     var result = "";
  1340.     var p = "";
  1341.     if (this!=null && typeof(this.cssPrefix)!="undefined" && this.cssPrefix!=null && this.cssPrefix!="") { p=this.cssPrefix; }
  1342.     result += "<STYLE>\n";
  1343.     result += "."+p+"cpYearNavigation,."+p+"cpMonthNavigation { background-color:#C0C0C0; text-align:center; vertical-align:center; text-decoration:none; color:#000000; font-weight:bold; }\n";
  1344.     result += "."+p+"cpDayColumnHeader, ."+p+"cpYearNavigation,."+p+"cpMonthNavigation,."+p+"cpCurrentMonthDate,."+p+"cpCurrentMonthDateDisabled,."+p+"cpOtherMonthDate,."+p+"cpOtherMonthDateDisabled,."+p+"cpCurrentDate,."+p+"cpCurrentDateDisabled,."+p+"cpTodayText,."+p+"cpTodayTextDisabled,."+p+"cpText { font-family:arial; font-size:8pt; }\n";
  1345.     result += "TD."+p+"cpDayColumnHeader { text-align:right; border:solid thin #C0C0C0;border-width:0px 0px 1px 0px; }\n";
  1346.     result += "."+p+"cpCurrentMonthDate, ."+p+"cpOtherMonthDate, ."+p+"cpCurrentDate  { text-align:right; text-decoration:none; }\n";
  1347.     result += "."+p+"cpCurrentMonthDateDisabled, ."+p+"cpOtherMonthDateDisabled, ."+p+"cpCurrentDateDisabled { color:#D0D0D0; text-align:right; text-decoration:line-through; }\n";
  1348.     result += "."+p+"cpCurrentMonthDate, .cpCurrentDate { color:#000000; }\n";
  1349.     result += "."+p+"cpOtherMonthDate { color:#808080; }\n";
  1350.     result += "TD."+p+"cpCurrentDate { color:white; background-color: #C0C0C0; border-width:1px; border:solid thin #800000; }\n";
  1351.     result += "TD."+p+"cpCurrentDateDisabled { border-width:1px; border:solid thin #FFAAAA; }\n";
  1352.     result += "TD."+p+"cpTodayText, TD."+p+"cpTodayTextDisabled { border:solid thin #C0C0C0; border-width:1px 0px 0px 0px;}\n";
  1353.     result += "A."+p+"cpTodayText, SPAN."+p+"cpTodayTextDisabled { height:20px; }\n";
  1354.     result += "A."+p+"cpTodayText { color:black; }\n";
  1355.     result += "."+p+"cpTodayTextDisabled { color:#D0D0D0; }\n";
  1356.     result += "."+p+"cpBorder { border:solid thin #808080; }\n";
  1357.     result += "</STYLE>\n";
  1358.     return result;
  1359.     }
  1360.  
  1361. // Return a string containing all the calendar code to be displayed
  1362. function CP_getCalendar() {
  1363.     var now = new Date();
  1364.     // Reference to window
  1365.     if (this.type == "WINDOW") { var windowref = "window.opener."; }
  1366.     else { var windowref = ""; }
  1367.     var result = "";
  1368.     // If POPUP, write entire HTML document
  1369.     if (this.type == "WINDOW") {
  1370.         result += "<HTML><HEAD><TITLE>Calendar</TITLE>"+this.getStyles()+"</HEAD><BODY MARGINWIDTH=0 MARGINHEIGHT=0 TOPMARGIN=0 RIGHTMARGIN=0 LEFTMARGIN=0>\n";
  1371.         result += '<CENTER><TABLE WIDTH=100% BORDER=0 BORDERWIDTH=0 CELLSPACING=0 CELLPADDING=0>\n';
  1372.         }
  1373.     else {
  1374.         result += '<TABLE CLASS="'+this.cssPrefix+'cpBorder" WIDTH=144 BORDER=1 BORDERWIDTH=1 CELLSPACING=0 CELLPADDING=1>\n';
  1375.         result += '<TR><TD ALIGN=CENTER>\n';
  1376.         result += '<CENTER>\n';
  1377.         }
  1378.     // Code for DATE display (default)
  1379.     // -------------------------------
  1380.     if (this.displayType=="date" || this.displayType=="week-end") {
  1381.         if (this.currentDate==null) { this.currentDate = now; }
  1382.         if (arguments.length > 0) { var month = arguments[0]; }
  1383.             else { var month = this.currentDate.getMonth()+1; }
  1384.         if (arguments.length > 1 && arguments[1]>0 && arguments[1]-0==arguments[1]) { var year = arguments[1]; }
  1385.             else { var year = this.currentDate.getFullYear(); }
  1386.         var daysinmonth= new Array(0,31,28,31,30,31,30,31,31,30,31,30,31);
  1387.         if ( ( (year%4 == 0)&&(year%100 != 0) ) || (year%400 == 0) ) {
  1388.             daysinmonth[2] = 29;
  1389.             }
  1390.         var current_month = new Date(year,month-1,1);
  1391.         var display_year = year;
  1392.         var display_month = month;
  1393.         var display_date = 1;
  1394.         var weekday= current_month.getDay();
  1395.         var offset = 0;
  1396.         
  1397.         offset = (weekday >= this.weekStartDay) ? weekday-this.weekStartDay : 7-this.weekStartDay+weekday ;
  1398.         if (offset > 0) {
  1399.             display_month--;
  1400.             if (display_month < 1) { display_month = 12; display_year--; }
  1401.             display_date = daysinmonth[display_month]-offset+1;
  1402.             }
  1403.         var next_month = month+1;
  1404.         var next_month_year = year;
  1405.         if (next_month > 12) { next_month=1; next_month_year++; }
  1406.         var last_month = month-1;
  1407.         var last_month_year = year;
  1408.         if (last_month < 1) { last_month=12; last_month_year--; }
  1409.         var date_class;
  1410.         if (this.type!="WINDOW") {
  1411.             result += "<TABLE WIDTH=144 BORDER=0 BORDERWIDTH=0 CELLSPACING=0 CELLPADDING=0>";
  1412.             }
  1413.         result += '<TR>\n';
  1414.         var refresh = windowref+'CP_refreshCalendar';
  1415.         var refreshLink = 'javascript:' + refresh;
  1416.         if (this.isShowNavigationDropdowns) {
  1417.             result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="78" COLSPAN="3"><select CLASS="'+this.cssPrefix+'cpMonthNavigation" name="cpMonth" onChange="'+refresh+'('+this.index+',this.options[this.selectedIndex].value-0,'+(year-0)+');">';
  1418.             for( var monthCounter=1; monthCounter<=12; monthCounter++ ) {
  1419.                 var selected = (monthCounter==month) ? 'SELECTED' : '';
  1420.                 result += '<option value="'+monthCounter+'" '+selected+'>'+this.monthNames[monthCounter-1]+'</option>';
  1421.                 }
  1422.             result += '</select></TD>';
  1423.             result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="10"> </TD>';
  1424.  
  1425.             result += '<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="56" COLSPAN="3"><select CLASS="'+this.cssPrefix+'cpYearNavigation" name="cpYear" onChange="'+refresh+'('+this.index+','+month+',this.options[this.selectedIndex].value-0);">';
  1426.             for( var yearCounter=year-this.yearSelectStartOffset; yearCounter<=year+this.yearSelectStartOffset; yearCounter++ ) {
  1427.                 var selected = (yearCounter==year) ? 'SELECTED' : '';
  1428.                 result += '<option value="'+yearCounter+'" '+selected+'>'+yearCounter+'</option>';
  1429.                 }
  1430.             result += '</select></TD>';
  1431.             }
  1432.         else {
  1433.             if (this.isShowYearNavigation) {
  1434.                 result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="10"><A CLASS="'+this.cssPrefix+'cpMonthNavigation" HREF="'+refreshLink+'('+this.index+','+last_month+','+last_month_year+');"><</A></TD>';
  1435.                 result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="58"><SPAN CLASS="'+this.cssPrefix+'cpMonthNavigation">'+this.monthNames[month-1]+'</SPAN></TD>';
  1436.                 result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="10"><A CLASS="'+this.cssPrefix+'cpMonthNavigation" HREF="'+refreshLink+'('+this.index+','+next_month+','+next_month_year+');">></A></TD>';
  1437.                 result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="10"> </TD>';
  1438.  
  1439.                 result += '<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="10"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="'+refreshLink+'('+this.index+','+month+','+(year-1)+');"><</A></TD>';
  1440.                 if (this.isShowYearNavigationInput) {
  1441.                     result += '<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="36"><INPUT NAME="cpYear" CLASS="'+this.cssPrefix+'cpYearNavigation" SIZE="4" MAXLENGTH="4" VALUE="'+year+'" onBlur="'+refresh+'('+this.index+','+month+',this.value-0);"></TD>';
  1442.                     }
  1443.                 else {
  1444.                     result += '<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="36"><SPAN CLASS="'+this.cssPrefix+'cpYearNavigation">'+year+'</SPAN></TD>';
  1445.                     }
  1446.                 result += '<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="10"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="'+refreshLink+'('+this.index+','+month+','+(year+1)+');">></A></TD>';
  1447.                 }
  1448.             else {
  1449.                 result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="22"><A CLASS="'+this.cssPrefix+'cpMonthNavigation" HREF="'+refreshLink+'('+this.index+','+last_month+','+last_month_year+');"><<</A></TD>\n';
  1450.                 result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="100"><SPAN CLASS="'+this.cssPrefix+'cpMonthNavigation">'+this.monthNames[month-1]+' '+year+'</SPAN></TD>\n';
  1451.                 result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="22"><A CLASS="'+this.cssPrefix+'cpMonthNavigation" HREF="'+refreshLink+'('+this.index+','+next_month+','+next_month_year+');">>></A></TD>\n';
  1452.                 }
  1453.             }
  1454.         result += '</TR></TABLE>\n';
  1455.         result += '<TABLE WIDTH=120 BORDER=0 CELLSPACING=0 CELLPADDING=1 ALIGN=CENTER>\n';
  1456.         result += '<TR>\n';
  1457.         for (var j=0; j<7; j++) {
  1458.  
  1459.             result += '<TD CLASS="'+this.cssPrefix+'cpDayColumnHeader" WIDTH="14%"><SPAN CLASS="'+this.cssPrefix+'cpDayColumnHeader">'+this.dayHeaders[(this.weekStartDay+j)%7]+'</TD>\n';
  1460.             }
  1461.         result += '</TR>\n';
  1462.         for (var row=1; row<=6; row++) {
  1463.             result += '<TR>\n';
  1464.             for (var col=1; col<=7; col++) {
  1465.                 var disabled=false;
  1466.                 if (this.disabledDatesExpression!="") {
  1467.                     var ds=""+display_year+LZ(display_month)+LZ(display_date);
  1468.                     eval("disabled=("+this.disabledDatesExpression+")");
  1469.                     }
  1470.                 var dateClass = "";
  1471.                 if ((display_month == this.currentDate.getMonth()+1) && (display_date==this.currentDate.getDate()) && (display_year==this.currentDate.getFullYear())) {
  1472.                     dateClass = "cpCurrentDate";
  1473.                     }
  1474.                 else if (display_month == month) {
  1475.                     dateClass = "cpCurrentMonthDate";
  1476.                     }
  1477.                 else {
  1478.                     dateClass = "cpOtherMonthDate";
  1479.                     }
  1480.                 if (disabled || this.disabledWeekDays[col-1]) {
  1481.                     result += '    <TD CLASS="'+this.cssPrefix+dateClass+'"><SPAN CLASS="'+this.cssPrefix+dateClass+'Disabled">'+display_date+'</SPAN></TD>\n';
  1482.                     }
  1483.                 else {
  1484.                     var selected_date = display_date;
  1485.                     var selected_month = display_month;
  1486.                     var selected_year = display_year;
  1487.                     if (this.displayType=="week-end") {
  1488.                         var d = new Date(selected_year,selected_month-1,selected_date,0,0,0,0);
  1489.                         d.setDate(d.getDate() + (7-col));
  1490.                         selected_year = d.getYear();
  1491.                         if (selected_year < 1000) { selected_year += 1900; }
  1492.                         selected_month = d.getMonth()+1;
  1493.                         selected_date = d.getDate();
  1494.                         }
  1495.                     result += '    <TD CLASS="'+this.cssPrefix+dateClass+'"><A HREF="javascript:'+windowref+this.returnFunction+'('+selected_year+','+selected_month+','+selected_date+');'+windowref+'CP_hideCalendar(\''+this.index+'\');" CLASS="'+this.cssPrefix+dateClass+'">'+display_date+'</A></TD>\n';
  1496.                     }
  1497.                 display_date++;
  1498.                 if (display_date > daysinmonth[display_month]) {
  1499.                     display_date=1;
  1500.                     display_month++;
  1501.                     }
  1502.                 if (display_month > 12) {
  1503.                     display_month=1;
  1504.                     display_year++;
  1505.                     }
  1506.                 }
  1507.             result += '</TR>';
  1508.             }
  1509.         var current_weekday = now.getDay() - this.weekStartDay;
  1510.         if (current_weekday < 0) {
  1511.             current_weekday += 7;
  1512.             }
  1513.         result += '<TR>\n';
  1514.         result += '    <TD COLSPAN=7 ALIGN=CENTER CLASS="'+this.cssPrefix+'cpTodayText">\n';
  1515.         if (this.disabledDatesExpression!="") {
  1516.             var ds=""+now.getFullYear()+LZ(now.getMonth()+1)+LZ(now.getDate());
  1517.             eval("disabled=("+this.disabledDatesExpression+")");
  1518.             }
  1519.         if (disabled || this.disabledWeekDays[current_weekday+1]) {
  1520.             result += '        <SPAN CLASS="'+this.cssPrefix+'cpTodayTextDisabled">'+this.todayText+'</SPAN>\n';
  1521.             }
  1522.         else {
  1523.             result += '        <A CLASS="'+this.cssPrefix+'cpTodayText" HREF="javascript:'+windowref+this.returnFunction+'(\''+now.getFullYear()+'\',\''+(now.getMonth()+1)+'\',\''+now.getDate()+'\');'+windowref+'CP_hideCalendar(\''+this.index+'\');">'+this.todayText+'</A>\n';
  1524.             }
  1525.         result += '        <BR>\n';
  1526.         result += '    </TD></TR></TABLE></CENTER></TD></TR></TABLE>\n';
  1527.     }
  1528.  
  1529.     // Code common for MONTH, QUARTER, YEAR
  1530.     // ------------------------------------
  1531.     if (this.displayType=="month" || this.displayType=="quarter" || this.displayType=="year") {
  1532.         if (arguments.length > 0) { var year = arguments[0]; }
  1533.         else { 
  1534.             if (this.displayType=="year") {    var year = now.getFullYear()-this.yearSelectStartOffset; }
  1535.             else { var year = now.getFullYear(); }
  1536.             }
  1537.         if (this.displayType!="year" && this.isShowYearNavigation) {
  1538.             result += "<TABLE WIDTH=144 BORDER=0 BORDERWIDTH=0 CELLSPACING=0 CELLPADDING=0>";
  1539.             result += '<TR>\n';
  1540.             result += '    <TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="22"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="javascript:'+windowref+'CP_refreshCalendar('+this.index+','+(year-1)+');"><<</A></TD>\n';
  1541.             result += '    <TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="100">'+year+'</TD>\n';
  1542.             result += '    <TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="22"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="javascript:'+windowref+'CP_refreshCalendar('+this.index+','+(year+1)+');">>></A></TD>\n';
  1543.             result += '</TR></TABLE>\n';
  1544.             }
  1545.         }
  1546.         
  1547.     // Code for MONTH display 
  1548.     // ----------------------
  1549.     if (this.displayType=="month") {
  1550.         // If POPUP, write entire HTML document
  1551.         result += '<TABLE WIDTH=120 BORDER=0 CELLSPACING=1 CELLPADDING=0 ALIGN=CENTER>\n';
  1552.         for (var i=0; i<4; i++) {
  1553.             result += '<TR>';
  1554.             for (var j=0; j<3; j++) {
  1555.                 var monthindex = ((i*3)+j);
  1556.                 result += '<TD WIDTH=33% ALIGN=CENTER><A CLASS="'+this.cssPrefix+'cpText" HREF="javascript:'+windowref+this.returnMonthFunction+'('+year+','+(monthindex+1)+');'+windowref+'CP_hideCalendar(\''+this.index+'\');" CLASS="'+date_class+'">'+this.monthAbbreviations[monthindex]+'</A></TD>';
  1557.                 }
  1558.             result += '</TR>';
  1559.             }
  1560.         result += '</TABLE></CENTER></TD></TR></TABLE>\n';
  1561.         }
  1562.     
  1563.     // Code for QUARTER display
  1564.     // ------------------------
  1565.     if (this.displayType=="quarter") {
  1566.         result += '<BR><TABLE WIDTH=120 BORDER=1 CELLSPACING=0 CELLPADDING=0 ALIGN=CENTER>\n';
  1567.         for (var i=0; i<2; i++) {
  1568.             result += '<TR>';
  1569.             for (var j=0; j<2; j++) {
  1570.                 var quarter = ((i*2)+j+1);
  1571.                 result += '<TD WIDTH=50% ALIGN=CENTER><BR><A CLASS="'+this.cssPrefix+'cpText" HREF="javascript:'+windowref+this.returnQuarterFunction+'('+year+','+quarter+');'+windowref+'CP_hideCalendar(\''+this.index+'\');" CLASS="'+date_class+'">Q'+quarter+'</A><BR><BR></TD>';
  1572.                 }
  1573.             result += '</TR>';
  1574.             }
  1575.         result += '</TABLE></CENTER></TD></TR></TABLE>\n';
  1576.         }
  1577.  
  1578.     // Code for YEAR display
  1579.     // ---------------------
  1580.     if (this.displayType=="year") {
  1581.         var yearColumnSize = 4;
  1582.         result += "<TABLE WIDTH=144 BORDER=0 BORDERWIDTH=0 CELLSPACING=0 CELLPADDING=0>";
  1583.         result += '<TR>\n';
  1584.         result += '    <TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="50%"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="javascript:'+windowref+'CP_refreshCalendar('+this.index+','+(year-(yearColumnSize*2))+');"><<</A></TD>\n';
  1585.         result += '    <TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="50%"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="javascript:'+windowref+'CP_refreshCalendar('+this.index+','+(year+(yearColumnSize*2))+');">>></A></TD>\n';
  1586.         result += '</TR></TABLE>\n';
  1587.         result += '<TABLE WIDTH=120 BORDER=0 CELLSPACING=1 CELLPADDING=0 ALIGN=CENTER>\n';
  1588.         for (var i=0; i<yearColumnSize; i++) {
  1589.             for (var j=0; j<2; j++) {
  1590.                 var currentyear = year+(j*yearColumnSize)+i;
  1591.                 result += '<TD WIDTH=50% ALIGN=CENTER><A CLASS="'+this.cssPrefix+'cpText" HREF="javascript:'+windowref+this.returnYearFunction+'('+currentyear+');'+windowref+'CP_hideCalendar(\''+this.index+'\');" CLASS="'+date_class+'">'+currentyear+'</A></TD>';
  1592.                 }
  1593.             result += '</TR>';
  1594.             }
  1595.         result += '</TABLE></CENTER></TD></TR></TABLE>\n';
  1596.         }
  1597.     // Common
  1598.     if (this.type == "WINDOW") {
  1599.         result += "</BODY></HTML>\n";
  1600.         }
  1601.     return result;
  1602.     }
  1603.     
  1604.     /**
  1605.      * WEB.DE Extension:
  1606.      * Clear all disabled days
  1607.      */
  1608.     function CP_clearDisabledDays() {
  1609.         this.disabledDatesExpression = '';
  1610.     }
  1611.